<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>click</button>
    <script>
        var btn = document.querySelector('button');
        //页面加载完成后执行
        window.onload  = function() {
            document.write('<div>666</div>')
        }
        // btn.onclick = function () {
        //     当文档加载完成后再执行 会重绘页面 使得页面最后只剩<div>666</div>
        //     document.write('<div>666</div>')
        // }
        //document.write('<div>666</div>')
    </script>
    <p>1</p>
    <div>2</div>
</body>

</html>